package com.edu.helloandroid01;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MyMainActivity extends Activity {
	private Button mybuttonshow = null;
	private Button mybuttonhide = null;
	private TextView mytextview =null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_main);
        mybuttonshow = (Button) this.findViewById(R.id.myButton1);
        mybuttonhide = (Button) this.findViewById(R.id.mybutton2);
        mytextview = (TextView) this.findViewById(R.id.myTextView1);
        mybuttonshow.setText("show");
        mybuttonhide.setText("hide");
        mytextview.setText("my first activity");
        
        MyButtonListener mybuttonlistener;
        
        mybuttonlistener = new MyButtonListener();
        
        mybuttonshow.setOnClickListener(mybuttonlistener);
        mybuttonhide.setOnClickListener(mybuttonlistener);
        
    }

    class MyButtonListener implements OnClickListener
    {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			switch (arg0.getId()) {
			case R.id.myButton1:
				mytextview.setVisibility(View.VISIBLE);
				break;
			case R.id.mybutton2:
				mytextview.setVisibility(View.INVISIBLE);
				break;
			default:
				break;
			}
			
		}


    	
    }
    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my_main, menu);
        return true;
    }
    
}
